package com.mitaotao._1_语法._4_循环.单循环._01_输出最大值;

import java.util.Scanner;

public class _01_1_依次输入10个数输出最大值 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        /*
        System.out.println("请输入第一个数字：");
        int num1 = scanner.nextInt();
        System.out.println("请输入第二个数字：");
        int num2 = scanner.nextInt();
        System.out.println("请输入第三个数字：");
        int num3 = scanner.nextInt();
        System.out.println("请输入第四个数字：");
        int num4 = scanner.nextInt();
        System.out.println("请输入第五个数字：");
        int num5 = scanner.nextInt();
        System.out.println("请输入第六个数字：");
        int num6 = scanner.nextInt();
        System.out.println("请输入第七个数字：");
        int num7 = scanner.nextInt();
        System.out.println("请输入第八个数字：");
        int num8 = scanner.nextInt();
        System.out.println("请输入第九个数字：");
        int num9 = scanner.nextInt();
        System.out.println("请输入第十个数字：");
        int num10 = scanner.nextInt();
         */
        System.out.println("请输入10个数字：");
        //定义数组array
        int[] array = new int[10];
        for (int n=0;n<array.length;n++){
            array[n] = scanner.nextInt();
        }
        //输出数组
        System.out.println(java.util.Arrays.toString(array));
        //定义空变量
        int temp;
        //冒泡排序
        for(int i=0;i<array.length;i++){
            for (int j=0;j<array.length-i-1;j++) {
                if (array[j] > array[j + 1]) {
                    temp = array[j];
                    array[j] = array[j+1];
                    array[j+1] = temp;
                }
            }
        }
        System.out.println("最大数字为："+array[9]);
        scanner.close();
    }

}

